#include "Task.hpp"
#include "ThreadPool.hpp"
#include <memory>
#include <time.h>
int main()
{
    srand(time(nullptr) ^ getpid());

    //std::unique_ptr<ThreadPool<Task>> tp = std::make_unique<ThreadPool<Task>>(10);
    // std::unique_ptr<ThreadPool<Task>> tp2 = std::make_unique<ThreadPool<Task>>(10);
    // std::unique_ptr<ThreadPool<Task>> tp3 = std::make_unique<ThreadPool<Task>>(10);
    //tp->Start();

    int cnt = 10;
    while(cnt--)
    {
        // 生产任务
        int x = rand()%10 + 1;
        usleep(rand()%73);
        int y = rand() % 5 + 1;
        Task t(x, y);

        // push到线程池中，处理
        // 如果线程池本身，被多线程访问呢？
        ThreadPool<Task>::GetInstance()->push(t);
        sleep(1);
    }

    ThreadPool<Task>::GetInstance()->Stop();

    ThreadPool<Task>::GetInstance()->Wait();

    // tp->Enqueue();

    return 0;
}